Skip to content

Fix invalid JSON/XML output when interface alias contains special characters - #293

Merged
vergoh merged 2 commits into
vergoh:masterfrom
wamuir:escape-alias-output
Oct 22, 2026
Merged

vergoh merged 2 commits into
vergoh:masterfrom
wamuir:escape-alias-output

Conversation

@wamuir

@wamuir wamuir commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Interface names and aliases are printed unescaped in --xml and --json output, so an alias containing reserved characters produces a document that fails to parse.

XML changes:

  • Reserved characters (&, <, >, ', ") are escaped as xml entities
  • Control characters other than tab, newline and carriage return are stripped

JSON changes:

  • " and \ are backslash escaped
  • Control characters are escaped as \u00XX

Adds tests covering both outputs.

@vergoh

vergoh commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Thanks. That's a good improvement and looks to be something I missed while doing partially related refactoring to the example cgis.

@vergoh
vergoh merged commit ff6a12a into vergoh:master Oct 22, 2026
10 checks passed
@wamuir

wamuir commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@vergoh yep! I've used vnstat for several years, appreciate the effort that you've put into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants